#include <stdio.h>
#include "driver/uart.h"
#include "driver/gpio.h"

static uint8_t uart_buffer[1024];


void app_main(void)
{
    uart_config_t uart_cfg={
        .baud_rate=115200,                          //波特率115200
        .data_bits=UART_DATA_8_BITS,                //8位数据位
        .flow_ctrl=UART_HW_FLOWCTRL_DISABLE,        //无硬件流控制
        .parity=UART_PARITY_DISABLE,                //无校验位
        .stop_bits=UART_STOP_BITS_1                 //1位停止位
    };
    uart_param_config(UART_NUM_1,&uart_cfg);
    uart_set_pin(UART_NUM_1,GPIO_NUM_32,GPIO_NUM_33,UART_PIN_NO_CHANGE,UART_PIN_NO_CHANGE); //设置引脚,tx为32,rx为33
    uart_driver_install(UART_NUM_1,1024,1024,0,NULL,0);     //安装串口驱动

    while(1)
    {
        int rec = uart_read_bytes(UART_NUM_1,uart_buffer,sizeof(uart_buffer),pdMS_TO_TICKS(100));
        if(rec)
        {
            uart_write_bytes(UART_NUM_1,uart_buffer,rec);
        }
    }

}   
